/**
 * 用户相关请求模块
 */
import request from '@/utils/request'
// import store from '@/store'

export const login = (data) => {
  return request({
    method: 'POST',
    url: '/v1_0/authorizations',
    data
  })
}

/**
 * 发送验证码
 * @param {*} mobile
 * 注意：每个手机号每分钟只能发一次
 * @returns
 */
export const sendSms = (mobile) => {
  return request({
    method: 'GET',
    url: `/v1_0/authorizations/${mobile}`
  })
}

/**
 * 获取用户个人的信息
 * @returns
 */
export const getUserInfo = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user'
    // 发送请求头
    /*  headers: {
      // 注意：该接口需要授权才能访问
      Authorization: `Bearer ${store.state.user.token}`
    } */
  })
}

/**
 * 获取用户频道信息home组件里面
 * @returns
 */
export const getUserChannels = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user/channels'
  })
}
/**
 * 用户添加关注
 * @param {*} target
 * @returns
 */
export const addFollow = (target) => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target
    }
  })
}
/**
 * 用户取消关注
 * @param {*} target
 * @returns
 */
export const deleteFollow = (target) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/user/followings/${target}`
  })
}

/**
 * 获取当前用户的个人资料
 * @returns
 */
export const getUserProfile = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user/profile'
  })
}
/**
 * 修改个人信息
 * @param {*} data
 * @returns
 */
export const updateUserProfile = (data) => {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/profile',
    data
  })
}
/**
 * 修改头像
 * @param {*} data
 * @returns
 */
export const updateUserPhoto = (data) => {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/photo',
    data
  })
}
